package com.duapk.search.servlet;

import java.io.File;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.duapk.nlp.constant.ChineseConstants;
import com.duapk.search.conf.ConfigFactory;
import com.duapk.search.conf.LogConfig;
import com.duapk.search.constant.Constant;
import com.duapk.search.work.IndexSearcherManager;
import com.duapk.search.work.RewriterProxy;

/**
 * 系统初始化
 * 
 * @Package: com.duapk.search.servlet
 * @ClassName: SystemInitListener
 * @author: jiangzheng
 * @date: Apr 4, 2011 10:43:23 PM
 * 
 */
public class SystemInitListener implements ServletContextListener {

	public void contextInitialized(ServletContextEvent arg0) {
		String confPath = Constant.APP_PATH + File.separator + "conf";
		ConfigFactory.init(confPath + File.separator + "config.xml");
		LogConfig.config(confPath + File.separator + "logback.xml");
		if (System.getProperty(ChineseConstants.CHINESE_WORD_PATH) == null) {
			System.setProperty(ChineseConstants.CHINESE_WORD_PATH,
					ConfigFactory.getString("Path.modelsDir"));
		}
		RewriterProxy.getInstance();

		IndexSearcherManager.init();
	}

	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub

	}
}
